//
//  NSString+DeviceType.m
//  RuiHeApp
//
//  Created by Yan Chen on 2025/3/18.
//

#import "NSString+DeviceType.h"

@implementation NSString (DeviceType)
-(BOOL)is233DeviceType
{
    BOOL is233 = [self isEqualToString:R_SM233120A0_US]||
                [self isEqualToString:K_KS233125A0_US]||
                [self isEqualToString:R_SM233120A0_EU]||
                [self isEqualToString:K_KS233125A0_EU];
    return is233;
}

///是否61度电设备
-(BOOL)is61DeviceType
{
    BOOL is61 = [self isEqualToString:R_EC061060D0]||
                [self isEqualToString:K_EC061060D0];
    return is61;
}

///是否储充一体
-(BOOL)isXStack
{
    BOOL isXStack = [self isEqualToString:K_XStack]||
                [self isEqualToString:R_XStack];
    return isXStack;
}

///是否高压设备
-(BOOL)isHVDeviceType
{
    BOOL isHv= [self isEqualToString:@"XtremeHV1.0"]||
               [self isEqualToString:@"Power Matrix"]||
                [self isEqualToString:@"MATE_HV1.0"];
    return isHv;
}

///根据端点类型获取参数前缀
+(NSString*)getEndpointParaPrefixStringWithEndpointCode:(NSString*)endpointCode deviceTypeCode:(NSString*)deviceTypeCode
{
    NSString *prefixKey = @"";
    if ([endpointCode isEqualToString:@"EMS"]) {
        prefixKey = @"Ems_";
        if ([deviceTypeCode is61DeviceType]) {
            prefixKey = @"EMS_";
        }
    }
    if ([endpointCode isEqualToString:@"EMU"]) {
        prefixKey = @"Emu_";
    }
    if ([endpointCode isEqualToString:@"Master"]) {
        prefixKey = @"Mtr_";
        if ([deviceTypeCode isEqualToString:R_EC215100D0]) {
            prefixKey = @"Matser_";
        }
    }
    if ([endpointCode isEqualToString:@"Pack"]) {
        prefixKey = @"Pck_";
    }
    
    if ([endpointCode isEqualToString:@"InvVoltronicLv"]) {
        prefixKey = @"Inv1_";
    }
    
    if ([endpointCode isEqualToString:@"InvRenacHv"]) {
        prefixKey = @"Inv2_";
    }
    
    if ([endpointCode isEqualToString:@"InvMegarevoLv"]) {
        prefixKey = @"Inv3_";
    }
    //233kWh PCS 美规
    if ([endpointCode isEqualToString:@"PcsKH"]) {
        prefixKey = @"PcsKH_";
    }
    //233kWh PCS 欧规
    if ([endpointCode isEqualToString:@"PcsYT"]) {
        prefixKey = @"PcsYT_";
    }
    //61kWh PCS  天青
    if ([endpointCode isEqualToString:@"PcsTQ"]) {
        prefixKey = @"PcsTQ_";
    }
    
    //61kWh PCS  锦浪
    if ([endpointCode isEqualToString:@"PcsJL"]) {
        prefixKey = @"PcsJL_";
    }
    //61kWh PCS  so-ark
    if ([endpointCode isEqualToString:@"PcsSA"]) {
        prefixKey = @"PcsSA_";
    }
    
    //1.67M
    if ([endpointCode isEqualToString:@"PCS"]) {
        prefixKey = @"PCS_";
        if ([deviceTypeCode isEqualToString:R_SM1672LCBO1_EU]) {
            prefixKey = @"PCSH_";
        }
    }
    //1.67M
    if ([endpointCode isEqualToString:@"BMS"]) {
        prefixKey = @"BMS_";
    }
    //1.67M
    if ([endpointCode isEqualToString:@"Cluster"]) {
        prefixKey = @"Cluster_";
    }
    //电表
    if ([endpointCode isEqualToString:@"MTR"]) {
        prefixKey = @"GrSmmtr_";
    }
    //液冷
    if ([endpointCode isEqualToString:@"LCU"]) {
        prefixKey = @"Lci_";
        if ([deviceTypeCode isEqualToString:R_SM1672LCBO1_EU]) {
            prefixKey = @"Lcu";
        }
    }
    //除湿机
    if ([endpointCode isEqualToString:@"DHM"]) {
        prefixKey = @"dehum_";
    }
    //除湿机
    if ([endpointCode isEqualToString:@"Dehumidifier"]) {
        prefixKey = @"Dehumidifier_";
    }
    
    //61kWh 风冷
    if ([endpointCode isEqualToString:@"ACU"]) {
        prefixKey = @"Acu_";
    }
    
    //215kWh DCDC
    if ([endpointCode isEqualToString:@"DCDC"]) {
        prefixKey = @"DCDC_";
    }
    return prefixKey;
}
@end
